package com.yunze.system.xsgl;

import com.alibaba.fastjson.JSON;
import com.rabbitmq.client.Channel;
import com.yunze.common.config.MyDictionary;
import com.yunze.common.core.redis.RedisCache;
import com.yunze.common.mapper.mysql.xsgl.customer.YzXsglCustomerAccountMapper;
import com.yunze.common.mapper.mysql.xsgl.customer.YzXsglCustomerMapper;
import com.yunze.common.mapper.mysql.xsgl.customer.YzXsglCustomerPeopleMapper;
import com.yunze.common.mapper.mysql.YzExecutionTaskMapper;
import com.yunze.common.utils.yunze.Different;
import com.yunze.common.utils.yunze.ExcelConfig;
import com.yunze.common.utils.yunze.VeDate;
import com.yunze.common.utils.yunze.WriteCSV;
import lombok.extern.slf4j.Slf4j;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import org.apache.commons.lang3.StringUtils;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 批量导入客户信息 消费 者
 */
@Slf4j
@Component
public class ImportCustomer {


    @Resource
    private RedisCache redisCache;
    @Resource
    private YzExecutionTaskMapper yzExecutionTaskMapper;
    @Resource
    private WriteCSV writeCSV;
    @Resource
    private YzXsglCustomerMapper yzXsglCustomerMapper;
    @Resource
    private YzXsglCustomerAccountMapper yzXsglCustomerAccountMapper;
    @Resource
    private YzXsglCustomerPeopleMapper yzXsglCustomerPeopleMapper;
    @Resource
    private MyDictionary myDictionary;

    /**
     * 批量客户信息
     *
     * @param msg
     * @param channel
     * @throws IOException
     */
    @RabbitHandler
    @RabbitListener(queues = "admin_uploadCustomer_queue")
    public void Cardsave(String msg, Channel channel) throws IOException {
        try {
            if (StringUtils.isEmpty(msg)) {
                return;
            }
            Map<String, Object> map = JSON.parseObject(msg);
            String filePath = map.get("filePath").toString();//项目根目录
            String ReadName = map.get("ReadName").toString();//上传新文件名
            String newName = map.get("newName").toString();//输出文件名
            Map<String, Object> User = (Map<String, Object>) map.get("User");//登录用户信息
//
//            String prefix = "admin_uploadCustomer_queue";
//            //执行前判断 redis 是否存在 执行数据 存在时 不执行
//            Object isExecute = redisCache.getCacheObject(prefix + ":" + ReadName);
//            if (isExecute == null) {
//                //System.out.println("SUCCESS");
//                redisCache.setCacheObject(prefix + ":" + ReadName, msg, 30, TimeUnit.SECONDS);//30 秒缓存 避免 重复消费
                Import(filePath, ReadName, User, newName);//执行导入
//            }
        } catch (Exception e) {
            log.error(">>错误 - 批量客户信息 消费者:{}<<", e.getMessage());
        }
    }


    /**
     * 导入客户信息执行
     *
     * @param filePath
     * @param ReadName
     * @param User
     * @param newName
     */
    public void Import(String filePath, String ReadName, Map<String, Object> User, String newName) {
        String path = filePath  + ReadName;
        ExcelConfig excelConfig = new ExcelConfig();
        //读取上传文件               dept_name	dname	grade_id	province	city	district	sort_id	one_category_id	two_category_id	source_id	credit_code	id_card	address	remarks	affiliation_id	tax_number	sales_id	合伙人费率	销售费率	售后费率
        String[] sheet1_columns = {"dept_name", "dname", "grade_id", "province", "city", "district", "sort_id", "one_category_id", "two_category_id", "source_id", "credit_code", "id_card", "address", "remarks", "affiliation_id", "tax_number", "sales_id"};
        String[] sheet2_columns = {"dept_name", "Cat_Name", "Cat_Bank_Name", "Cat_Number", "Cat_atId", "Cat_User_Name", "Cat_Zip_Code", "Cat_Address"};
        String[] sheet3_columns = {"dept_name", "name", "is_maste", "gender_id", "job_title", "telephone", "qq", "nailed", "email", "remarks"};
        Map<String, Object> Rmap = excelConfig.getExcelCustomer(path, sheet1_columns, sheet2_columns, sheet3_columns);


        List<Map<String, String>> list = new ArrayList<>();

        //获取企业信息 验证数据格式
        List<Map<String, String>> CMaplist = (List<Map<String, String>>) Rmap.get("CMaplist");
        List<Map<String, String>> CatArrslist = (List<Map<String, String>>) Rmap.get("CatArrslist");
        List<Map<String, String>> CpeopleArrslist = (List<Map<String, String>>) Rmap.get("CpeopleArrslist");


        List<Map<String, String>> Required_CMaplist = new ArrayList<>();//必填未填写 【主表信息】
        List<Map<String, String>> wrongFormat_CMaplist = new ArrayList<>();//填写数据不合格 【主表信息】


        for (int i = 0; i < CMaplist.size(); i++) {
            Map<String, String> Cmap = CMaplist.get(i);
            String dept_name = Cmap.get("dept_name") != null && Cmap.get("dept_name").length() > 0 ? Cmap.get("dept_name") : null;
            String dname = Cmap.get("dname") != null && Cmap.get("dname").length() > 0 ? Cmap.get("dname") : null;
            String grade_id = Cmap.get("grade_id") != null && Cmap.get("grade_id").length() > 0 ? Cmap.get("grade_id") : null;
            String province = Cmap.get("province") != null && Cmap.get("province").length() > 0 ? Cmap.get("province") : null;
            String city = Cmap.get("city") != null && Cmap.get("city").length() > 0 ? Cmap.get("city") : null;
            String district = Cmap.get("district") != null && Cmap.get("district").length() > 0 ? Cmap.get("district") : null;
            String sort_id = Cmap.get("sort_id") != null && Cmap.get("sort_id").length() > 0 ? Cmap.get("sort_id") : null;
            String one_category_id = Cmap.get("one_category_id") != null && Cmap.get("one_category_id").length() > 0 ? Cmap.get("one_category_id") : null;
            String two_category_id = Cmap.get("two_category_id") != null && Cmap.get("two_category_id").length() > 0 ? Cmap.get("two_category_id") : null;
            String source_id = Cmap.get("source_id") != null && Cmap.get("source_id").length() > 0 ? Cmap.get("source_id") : null;


            if (dept_name != null && dname != null && grade_id != null && province != null && city != null && district != null && sort_id != null && one_category_id != null && two_category_id != null && source_id != null) {
                String credit_code = Cmap.get("credit_code") != null && Cmap.get("credit_code").length() > 0 ? Cmap.get("credit_code") : null;
                String id_card = Cmap.get("id_card") != null && Cmap.get("id_card").length() > 0 ? Cmap.get("id_card") : null;
                if (sort_id.equals("企业")) {//&& credit_code!=null
                    list.add(Cmap);
                } else if (sort_id.equals("个人")) {// && id_card!=null
                    list.add(Cmap);
                } else {
                    wrongFormat_CMaplist.add(Cmap);
                }
            } else {
                Required_CMaplist.add(Cmap);
            }
        }

        Map<String, String> Dept = (Map<String, String>) User.get("dept");
        String create_by = " [ " + Dept.get("deptName") + " ] - " + " [ " + User.get("userName") + " ] ";

        String Outcolumns[] = {"客户名称", "【客户信息】操作描述", "【客户信息】执行结果", "【账号信息】操作描述", "【账号信息】执行结果", "【联系人信息】操作描述", "【联系人信息】执行结果", "执行时间", "执行结果", "执行人"};
        String keys[] = {"dept_name", "Cmap_description", "Cmap_result", "CatArrslist_description", "CatArrslist_result", "CpeopleArrslist_description", "CpeopleArrslist_result", "time", "result", "agentName"};

        if (Required_CMaplist.size() > 0) {
            Map<String, Object> defOutcolumns = new HashMap<>();
            defOutcolumns.put("message", "【客户信息】必填字段未填写");
            defOutcolumns.put("agentName", create_by);
            defOutcolumns.put("result", "操作取消");
            writeCSV.OutCSVStr(Required_CMaplist, newName, Outcolumns, keys, defOutcolumns, 10);
        }

        if (wrongFormat_CMaplist.size() > 0) {
            Map<String, Object> defOutcolumns = new HashMap<>();
            defOutcolumns.put("message", "【客户信息】填写数据不合格 如 客户类型为 企业时必填 社会企业代码，为 个人 时 必填 身份证号码！且不能与现有 社会企业代码，身份证号码重复！");
            defOutcolumns.put("agentName", create_by);
            defOutcolumns.put("result", "操作取消");
            writeCSV.OutCSVStr(wrongFormat_CMaplist, newName, Outcolumns, keys, defOutcolumns, 10);
        }

        String SaveUrl = "/getcsv/" + newName + ".csv";
        String task_name = "客户管理上传 [导入] ";
        Map<String, Object> task_map = new HashMap<String, Object>();
        task_map.put("auth", create_by);
        task_map.put("task_name", task_name);
        task_map.put("url", SaveUrl);
        task_map.put("agent_id", Dept.get("deptId"));
        task_map.put("type", "13");
        yzExecutionTaskMapper.add(task_map);//添加执行 任务表
        HashMap<String, Object> Is_exist_map = new HashMap<>();
        Is_exist_map.put("CMaplist", list);
        List<String> Is_existArr = yzXsglCustomerMapper.Is_exist(Is_exist_map);

        if (list != null && list.size() > 0) {


            //0.判断上传 企业名称是否已存在
            if (Is_existArr.size() > 0) {
                List<String> list1 = new ArrayList<>();
                for (int i = 0; i < list.size(); i++) {
                    list1.add(list.get(i).get("dept_name"));
                }
                //找出与数据库已存在 相同 ICCID 去除 重复 iccid
                List<Map<String, String>> Out_list_Different = Different.getIdentical(list1, Is_existArr, "dept_name");
                if (Out_list_Different.size() > 0) {
                    Map<String, Object> defOutcolumns = new HashMap<>();
                    defOutcolumns.put("message", "【客户信息】客户名称已存在 请勿重复导入！");
                    defOutcolumns.put("agentName", create_by);
                    defOutcolumns.put("result", "企业名导入失败");
                    writeCSV.OutCSVStr(wrongFormat_CMaplist, newName, Outcolumns, keys, defOutcolumns, 10);
                }
                list = Different.delIdentical(list, Is_existArr, "dept_name");//删除相同的数据 进行批量上传
            }


            //1.判断上传 企业是否已存在 系统企业 不存在时创建系统 企业
            if (list.size() > 0) {
                Is_exist_map.put("CMaplist", list);//更新 list
                List<Map<String, Object>> Is_existSysDeptArr = yzXsglCustomerMapper.Is_existSysDept(Is_exist_map);
                List<Map<String, String>> SaveSysDeptlist = new ArrayList<>();//系统企业 新增Arr
                if (Is_existSysDeptArr != null) {

                    //将以存在的企业id 赋值给需要新增的数据中
                    List<Map<String, String>> Set_list = new ArrayList<>();

                    Integer MaxOrderNum = yzXsglCustomerMapper.getMaxOrderNum();
                    MaxOrderNum = MaxOrderNum != null ? MaxOrderNum : 0;

                    for (int i = 0; i < list.size(); i++) {
                        Map<String, String> obj = list.get(i);
                        String l_dept_name = obj.get("dept_name");
                        MaxOrderNum += i + 1;
                        obj.put("order_num", MaxOrderNum.toString());
                        for (int j = 0; j < Is_existSysDeptArr.size(); j++) {
                            Map<String, Object> Sobj = Is_existSysDeptArr.get(j);
                            String s_dept_name = Sobj.get("dept_name").toString();
                            if (l_dept_name.equals(s_dept_name)) {
                                obj.put("dept_id", Sobj.get("dept_id").toString());
                                break;
                            }
                        }
                        Set_list.add(obj);
                    }
                    list = Set_list;//刷新赋值 dept_id
                    List<String> list2 = new ArrayList<>();
                    for (int i = 0; i < Is_existSysDeptArr.size(); i++) {
                        list2.add(Is_existSysDeptArr.get(i).get("dept_name").toString());
                    }
                    SaveSysDeptlist = Different.delIdentical(list, list2, "dept_name");//删除相同的数据
                } else {
                    SaveSysDeptlist = list;
                }
                //新增系统 企业
                if (SaveSysDeptlist.size() > 0) {
                    int saveCount = yzXsglCustomerMapper.saveSysDept(SaveSysDeptlist);
                    //插入成功之后将dept_id 更新至 list
                    if (saveCount > 0) {
                        List<Map<String, String>> Set_list = new ArrayList<>();
                        for (int i = 0; i < list.size(); i++) {
                            Map<String, String> obj = list.get(i);
                            String l_dept_name = obj.get("dept_name");
                            for (int j = 0; j < SaveSysDeptlist.size(); j++) {
                                Map<String, String> Sobj = SaveSysDeptlist.get(j);
                                String s_dept_name = Sobj.get("dept_name");
                                if (l_dept_name.equals(s_dept_name)) {
                                    obj.put("dept_id", Sobj.get("dept_id"));
                                    break;
                                }
                            }
                            Set_list.add(obj);
                        }
                        list = Set_list;//刷新赋值 dept_id

                        List<Map<String, String>> userList = new ArrayList<>();//用户
                        try {
                            HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
                            //拼音小写
                            format.setCaseType(HanyuPinyinCaseType.LOWERCASE);
                            //不带声调
                            format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);

                            String password = VeDate.getNowDateShortNuber();//获取密码
                            //新增企业下 登录账号信息
                            for (int i = 0; i < Set_list.size(); i++) {
                                Map<String, String> obj = Set_list.get(i);
                                // user_name 用户账号 nick_name 用户昵称
                                String nick_name = obj.get("dname");//中文转拼音
                                String user_name = PinyinHelper.toHanYuPinyinString(nick_name, format, ",", true);//中文转拼音
                                Map<String, String> map = new HashMap<>();
                                String Str = String.valueOf(obj.get("dept_id"));//把 int 转换成 字符串
                                map.put("dept_id", Str);
                                map.put("user_name", user_name.replaceAll(",",""));
                                map.put("nick_name", nick_name);
                                map.put("password", password);
                                userList.add(map);
                            }

                            if (userList.size() > 0) {

                                int userAdd = yzXsglCustomerMapper.userAdd(userList);//新增 账户 密码

                                //新增 企业下 登录账号信息 关联的角色信息 默认生成的客户角色id 为 2 和 4 两条数据
                                if(userAdd>0){
                                    List<Map<String, String>> rooleList = new ArrayList<>();//用户

                                    for (int i = 0; i < userList.size(); i++) {
                                        Map<String, String> user = userList.get(i);

                                        String Str = String.valueOf(user.get("user_id"));//把 int 转换成 字符串

                                        Map<String, String> map = new HashMap<>();

                                        map.put("user_id", Str);
                                        map.put("role_id", "2");

                                        Map<String, String> map_2 = new HashMap<>();
                                        map_2.put("user_id", Str);
                                        map_2.put("role_id", "4");

                                        rooleList.add(map);
                                        rooleList.add(map_2);
                                    }
                                    if(rooleList.size()>0){
                                      yzXsglCustomerMapper.userDept(rooleList);// 新增 用户和角色
                                    }
                                }
                            }
                        } catch (Exception e) {
                            System.out.println("生成账户密码--->失败");
                        }
                    }
                }
                //将 账户信息 客户联系人信息 打包到 对应的Map 里执行 新增
                if (list.size() > 0) {

                    List<Map<String, Object>> SaveList = new ArrayList<>();


                    //格式化数据
                    for (int i = 0; i < list.size(); i++) {
                        Map<String, String> obj = list.get(i);
                        String l_dept_name = obj.get("dept_name");
                        Map<String, Object> Pmap = new HashMap<>();
                        List<Map<String, String>> CatArrs = new ArrayList<>();
                        List<Map<String, String>> CpeopleArrs = new ArrayList<>();


                        String one_category_id = obj.get("one_category_id");
                        String two_category_id = obj.get("two_category_id");
                        String source_id = obj.get("source_id");
                        String grade_id = obj.get("grade_id");
                        String sort_id = obj.get("sort_id");

                        one_category_id = myDictionary.getdictValue("yz_customer_grade_one", one_category_id);
                        two_category_id = myDictionary.getdictValue("yz_customer_grade_tow", two_category_id);
                        source_id = myDictionary.getdictValue("yz_customer_source", source_id);
                        grade_id = myDictionary.getdictValue("yz_customer_grade", grade_id);
                        sort_id = myDictionary.getdictValue("yz_CustomerSort_type", sort_id);


                        obj.put("one_category_id", one_category_id);
                        obj.put("two_category_id", two_category_id);
                        obj.put("source_id", source_id);
                        obj.put("grade_id", grade_id);
                        obj.put("sort_id", sort_id);


                        for (int j = 0; j < CatArrslist.size(); j++) {
                            Map<String, String> C_obj = CatArrslist.get(j);
                            String C_dept_name = C_obj.get("dept_name");
                            if (l_dept_name.equals(C_dept_name)) {
                                CatArrs.add(C_obj);
                            }
                        }

                        for (int k = 0; k < CpeopleArrslist.size(); k++) {
                            Map<String, String> C_obj = CpeopleArrslist.get(k);
                            String C_dept_name = C_obj.get("dept_name");
                            if (l_dept_name.equals(C_dept_name)) {
                                CpeopleArrs.add(C_obj);
                            }
                        }

                        obj.put("c_name", obj.get("dept_name"));//赋值公司名称
                        Pmap.put("CMap", obj);
                        Pmap.put("CatArrs", CatArrs);
                        Pmap.put("CpeopleArrs", CpeopleArrs);
                        SaveList.add(Pmap);
                    }


                    try {
                        if (SaveList.size() > 0) {
                            List<Map<String, Object>> OutList = new ArrayList<>();

                            for (int i = 0; i < SaveList.size(); i++) {
                                Map<String, Object> SaveObj = SaveList.get(i);
                                Map<String, Object> CMap = (Map<String, Object>) SaveObj.get("CMap");
                                List<Map<String, Object>> CatArrs = (List<Map<String, Object>>) SaveObj.get("CatArrs");
                                List<Map<String, Object>> CpeopleArrs = (List<Map<String, Object>>) SaveObj.get("CpeopleArrs");
                                Map<String, Object> OutMap = new HashMap<>();

                                String Time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
                                String Cmap_result = "", CatArrslist_result = "", CpeopleArrslist_result = "", CatArrslist_description = "", CpeopleArrslist_description = "", Cmap_description = "", result = "";

                                try {
                                    Map<String, Object> RetMap = save(SaveObj);
                                    boolean bool = (boolean) RetMap.get("bool");
                                    boolean CatArrs_bool = (boolean) RetMap.get("CatArrs_bool");
                                    boolean CpeopleArrs_bool = (boolean) RetMap.get("CpeopleArrs_bool");
                                    int CatArrs_AddCount = Integer.parseInt(RetMap.get("CatArrs_AddCount").toString());
                                    int CpeopleArrs_AddCount = Integer.parseInt(RetMap.get("CpeopleArrs_AddCount").toString());
                                    if (bool) {
                                        Cmap_result = "成功";
                                    } else {
                                        Cmap_result = "失败";
                                    }
                                    Cmap_description = "新增客户 【" + Cmap_result + "】";
                                    if (CatArrs.size() > 0) {
                                        if (CatArrs_bool) {
                                            CatArrslist_result = "成功";
                                            CatArrslist_description = "成功新增账号【" + CatArrs_AddCount + "】条数据";
                                        } else {
                                            CatArrslist_result = "失败";
                                        }
                                    }

                                    if (CpeopleArrs.size() > 0) {
                                        if (CpeopleArrs_bool) {
                                            CpeopleArrslist_result = "成功";
                                            CpeopleArrslist_description = "成功新增 客户联系人【" + CpeopleArrs_AddCount + "】条数据";
                                        } else {
                                            CpeopleArrslist_result = "失败";
                                        }
                                    }
                                    result = "已执行";

                                } catch (Exception e) {
                                    result = "保存数据异常！";
                                    CatArrslist_result = "失败";
                                    CpeopleArrslist_result = "失败";
                                    Cmap_result = "失败";
                                    log.error(">> 导入客户-消费者- SaveObj 异常，SaveObj:{} | e.getMessage :{} <<", SaveObj, e.getMessage());
                                }
                                OutMap.put("dept_name", CMap.get("c_name"));
                                OutMap.put("Cmap_description", Cmap_description);
                                OutMap.put("Cmap_result", Cmap_result);
                                OutMap.put("CatArrslist_description", CatArrslist_description);
                                OutMap.put("CatArrslist_result", CatArrslist_result);
                                OutMap.put("CpeopleArrslist_description", CpeopleArrslist_description);
                                OutMap.put("CpeopleArrslist_result", CpeopleArrslist_result);
                                OutMap.put("time", Time);
                                OutMap.put("result", result);
                                OutMap.put("agentName", create_by);
                                OutList.add(OutMap);
                            }
                            if (OutList.size() > 0) {
                                writeCSV.OutCSVObj(OutList, newName, Outcolumns, keys, null, 10);
                            }
                        } else {
                            writeCSV.OutCSV(CMaplist, newName, "导入客户已全部在数据库中", create_by, "操作取消", Outcolumns, keys);
                            log.error(">> 导入客户-消费者- 上传数据已全部在数据库！ :{}<<");
                        }
                    } catch (DuplicateKeyException e) {
                        System.out.println("====" + e.getCause().toString());
                        String[] solit = e.getCause().toString().split("'");
                        writeCSV.OutCSV(list, newName, e.getCause().toString(), create_by, "导入失败", Outcolumns, keys);
                        yzExecutionTaskMapper.set_end_time(task_map);//任务结束
                        log.error(">> 导入客户-消费者- 上传excel异常 [插入数据 DuplicateKeyException ] :{}<<", e.getMessage().toString());
                    } catch (Exception e) {
                        writeCSV.OutCSV(list, newName, e.getCause().toString(), create_by, "导入失败", Outcolumns, keys);
                        yzExecutionTaskMapper.set_end_time(task_map);//任务结束
                        log.error(">>导入客户-消费者- 批量导入客户信息消费者:{}<<", e.getMessage().toString());
                    }
                } else {
                    writeCSV.OutCSV(CMaplist, newName, "导入客户已全部在数据库中", create_by, "操作取消", Outcolumns, keys);
                    log.info(">> 导入客户-消费者- 上传数据已全部在数据库！ :{}<<");
                }
            } else {
                writeCSV.OutCSV(CMaplist, newName, "导入客户已全部在数据库中", create_by, "操作取消", Outcolumns, keys);
                log.info(">> 导入客户-消费者- 上传数据已全部在数据库！ :{}<<");
            }
            yzExecutionTaskMapper.set_end_time(task_map);//任务结束
        } else {
            log.info("导入客户-消费者 上传表格无数据！无需执行导入");
        }

    }


    @Transactional
    public Map<String, Object> save(Map map) {
        Map<String, Object> CMap = (Map<String, Object>) map.get("CMap");
        Map<String, Object> Rmap = new HashMap<>();
        boolean bool = false, CatArrs_bool = false, CpeopleArrs_bool = false;
        int CatArrs_AddCount = 0, CpeopleArrs_AddCount = 0;
        //检查 CMap 新增 客户信息 是否已经存在
        // 新增主表
        bool = yzXsglCustomerMapper.save(CMap) > 0;
        map.put("CoID", CMap.get("id"));
        List<Map<String, Object>> CatArrs = (List<Map<String, Object>>) map.get("CatArrs");
        List<Map<String, Object>> CpeopleArrs = (List<Map<String, Object>>) map.get("CpeopleArrs");
        if (CatArrs != null && CatArrs.size() > 0) {
            CatArrs_AddCount = yzXsglCustomerAccountMapper.save(map);
            CatArrs_bool = CatArrs_AddCount > 0;
        }
        if (CpeopleArrs != null && CpeopleArrs.size() > 0) {
            CpeopleArrs_AddCount = yzXsglCustomerPeopleMapper.save(map);
            CpeopleArrs_bool = CpeopleArrs_AddCount > 0;
        }
        Rmap.put("bool", bool);
        Rmap.put("CatArrs_AddCount", CatArrs_AddCount);
        Rmap.put("CatArrs_bool", CatArrs_bool);
        Rmap.put("CpeopleArrs_AddCount", CpeopleArrs_AddCount);
        Rmap.put("CpeopleArrs_bool", CpeopleArrs_bool);
        return Rmap;
    }


}
